home *** CD-ROM | disk | FTP | other *** search
- Path: castle.nando.net!news
- From: actuary@nando.net (Bill McCarthy)
- Newsgroups: comp.lang.c
- Subject: Re: passing arguments to main()
- Date: 3 Mar 1996 00:03:13 GMT
- Organization: Nando.net Public Access
- Message-ID: <4hank1$k36@castle.nando.net>
- References: <4h78t1$nqq@netnews.upenn.edu>
- Reply-To: actuary@nando.net (Bill McCarthy)
- NNTP-Posting-Host: grail1703.nando.net
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <4h78t1$nqq@netnews.upenn.edu>, daniels@oasis.rad.upenn.edu (Jamie Daniels) writes:
- >Hello,
- >
- >I have a question about c I am not very good with programming. I have this
- >project that I want to take two strings one a name the other being an 80
- >character message(sentence). I want it to spit out a simplt print statement at
- >an Unix prompt. But I don't know how to pass arguments to main(). also I can't
- >get the output to be entered in at the unix prompt. I want the output to be a
- >command. for a simple example
- >
- > printf("ping 165.234.323.222");
- >
- >will not ping this address it only prints this statement before the prompt
- >
- > any help would be greatly appreciated
-
- I'm not familiar with Unix (although I've worked a bit with Linux), so there
- may be a preferably way to do this in a Unix environment. The ANSI C
- approach would be:
-
- #include <stdlib.h>
-
- int main( void )
- {
- system( "ping 165.234.323.222" );
- return EXIT_SUCCESS;
- }
-
- Bill McCarthy
- actuary@nando.net
- Wendell, NC USA
-